package com.crm.eg.action;

import java.util.List;

import com.crm.eg.bean.UserAccount;
import com.crm.eg.service.UserAccountService;
import com.crm.exception.DBException;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Preparable;
/**
 * 
 * Class Description :operate user Account action
 * <pre>
 * Filename			: UserAccountAction.java 
 * Date				: 2008-10-27
 * Creator			: liuqing
 * Revised Description
 * ----------------------------------------------
 * ver	revised date	reviser	revised contents
 * ----------------------------------------------
 * 1.0  2008-10-27         liuqing  
 *</pre>
 */
public class UserAccountAction implements Preparable {

	private UserAccountService userAccountService;

	private List<UserAccount> userAccounts;

	private UserAccount userAccount;

	private Long id;

	public String execute() throws DBException {
		try {
			userAccounts = userAccountService.getAllUserAccount();
			return Action.SUCCESS;
		} catch (DBException e) {
			throw e;
		}
	}

	public void prepare() throws DBException {

		try {
			if (id != null) {
				userAccountService.getUserAccountById(id);
			}

		} catch (DBException e) {
			throw e;
		}
	}
    
	public String save() throws DBException {
		try {
			userAccountService.saveUserAccount(userAccount);
			return Action.SUCCESS;
		} catch (DBException e) {
			throw e;
		}
	}
	
	public String remove() throws DBException {
		try {
			userAccountService.deleteUserAccount(id);
			return Action.SUCCESS;
		} catch (DBException e) {
			throw e;
		}
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public UserAccount getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}

	public List<UserAccount> getUserAccounts() {
		return userAccounts;
	}

	public void setUserAccounts(List<UserAccount> userAccounts) {
		this.userAccounts = userAccounts;
	}

	public UserAccountService getUserAccountService() {
		return userAccountService;
	}

	public void setUserAccountService(UserAccountService userAccountService) {
		this.userAccountService = userAccountService;
	}
}
